package db_main

import (
	"fmt"
	"longmen/server/pkg/common/helper/util"
	"longmen/server/pkg/db/mysql"
	"longmen/server/pkg/db/mysql/models/models_main"
)

func GetLotteryAwardConfigsByLottId(lottId int) ([]models_main.LotteryAwardConfig, error) {
	fName := "GetLotteryAwardConfigsByLottId"
	var o []models_main.LotteryAwardConfig
	err := mysql.GetRTable(&models_main.LotteryAwardConfig{}).
		Where("lott_id = ?", lottId).
		Order("sort asc").
		Find(&o).Error
	if err != nil {
		return nil, fmt.Errorf("%s%s", util.Convert(fName), err.Error())
	}
	return o, nil
}

func GetLotteryAwardConfigsByLottIds(lottIds []int) ([]models_main.LotteryAwardConfig, error) {
	fName := "GetLotteryAwardConfigsByLottIds"
	var o []models_main.LotteryAwardConfig
	err := mysql.GetRTable(&models_main.LotteryAwardConfig{}).
		Where("lott_id in ?", lottIds).
		Order("sort asc").
		Find(&o).Error
	if err != nil {
		return nil, fmt.Errorf("%s%s", util.Convert(fName), err.Error())
	}
	return o, nil
}
